/**********************************
 ***	Imports
 **********************************/
package fr.montreuil.wargame.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import fr.montreuil.wargame.domain.User;

/**********************************
 *** 	@jgay
 *** 	@9 mai 2012
 **********************************/
public class UserRegistrationValidator implements Validator{

	@Override
	public boolean supports(Class<?> clazz) {
		return User.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors error) {
		User user = (User) target;
		ValidationUtils.rejectIfEmptyOrWhitespace(error, "name", "user.name.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(error, "level", "user.level.required");
	}
}
